﻿/**
 * Circle
 *
 * @author		Allen Chou
 * @version		1.1.1 (last update: Dec 15 2008)
 * @link        http://cjcat.blogspot.com
 * @link		http://cjcat2266.deviantart.com
 */

package idv.cjcat.display.shapes {
	import flash.display.*;
	import flash.events.*;
	
	import idv.cjcat.display.*;
	
	/**
	 * The <code>Circle</code> class lets you conveniently creates a circle shape,
	 * whose style can be easily set by using <code>LineStyle</code> and <code>Fill</code>.
	 */
	public class Circle extends AbstractShape {
		
		/**
		 * The radius of the circle.
		 */
		public var radius:Number;
		
		/**
		 * Creates a circle.
		 * @param	radius     The radius of the circle.
		 * @param	fill       The fill of the circle.
		 * @param	lineStyle  The lineStyle of the circle.
		 */
		public function Circle(radius:Number = 50) {
			this.radius = radius;
			render();
		}
		
		/**
		 * Call this method after modifications to properties are made to update appearance.
		 * <p>This method can be used as an event listener.</p>
		 */
		public override function render(e:Event = null):void {
			graphics.clear();
			if ((this.lineStyle != null) || (this.lineStyle.alpha == 0)) CJDisplay.lineStyle(this, lineStyle);
			if ((this.fill != null) || (this.fill.alpha == 0)) CJDisplay.beginFill(this, fill);
			graphics.drawEllipse(-this.radius, -this.radius, this.radius * 2, this.radius * 2);
		}
		
	}
}